package v1

import (
	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/do"

	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/entity"

	uv1 "gitee.com/liangziyisheng/caas-platform-mc/api/user/v1"

	"github.com/gogf/gf/v2/frame/g"
)

type ListReq struct {
	g.Meta `path:"/groups" tags:"用户组管理" method:"get" summary:"用户组列表"`
	Name   string `json:"name"`
	Page   int    `json:"page"   v:"required|min:1"     description:"页码"`
	Size   int    `json:"size" v:"required|between:1,100"       description:"每页条数"`
}
type ListRes struct {
	g.Meta `mime:"application/json"`
	Data   []UserGroup `json:"data"`
	Total  int         `json:"total"`
}

type AssignUserReq struct {
	g.Meta `path:"/groups/{id}/users" tags:"用户组管理" method:"post" summary:"将用户分配给用户组"`
	Id     int64   `query:"id" json:"id" v:"required|min:1"`
	Users  []int64 `json:"users"`
}
type AssignUserRes struct {
	g.Meta `mime:"application/json"`
	Id     int64 `json:"id"`
}

type UnassignUserReq struct {
	g.Meta `path:"/groups/{id}/users" tags:"用户组管理" method:"delete" summary:"将用户从用户组中移除"`
	Id     int64   `query:"id" json:"id" v:"required|min:1"`
	Users  []int64 `json:"users"`
}

type UnassignUserRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows"`
}

type UserGroup struct {
	Id          int64  `json:"id"        description:""`
	Name        string `json:"name"           description:"用户组名称"`
	Description string `json:"description" description:"描述"`
}

type AddReq struct {
	g.Meta      `path:"/groups" tags:"用户组管理" method:"post" summary:"添加用户组"`
	Name        string `json:"name"           description:"用户组名称"`
	Description string `json:"description" description:"描述"`
}
type AddRes struct {
	g.Meta `mime:"application/json"`
	Id     int64 `json:"id" description:"用户组id"`
}

type UpdateReq struct {
	g.Meta      `path:"/groups/{id}" tags:"用户组管理" method:"put" summary:"更新用户组"`
	Id          int64  `query:"id" v:"required|min:1"`
	Description string `json:"description" description:"描述"`
}
type UpdateRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"修改成功的行数"`
}

type DeleteReq struct {
	g.Meta `path:"/groups/{id}" tags:"用户组管理" method:"delete" summary:"删除用户组"`
	Id     int64 `query:"id" v:"required|min:1"`
}
type DeleteRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"删除成功的行数"`
}

type InfoReq struct {
	g.Meta `path:"/groups/{id}" tags:"用户组管理" method:"get" summary:"用户组详情"`
	Id     int64 `query:"id" v:"required|min:1"`
}
type InfoRes struct {
	g.Meta `mime:"application/json"`
	Id     int64      `json:"id"`
	Users  []uv1.User `json:"users"`
}

type ListInput struct {
	TenantCode string `json:"tenantCode"`
	Name       string `json:"name"`
	Size       int    `json:"size"`
	Page       int    `json:"page"`
}
type ListOutput struct {
	Data  []entity.UserGroup `json:"data"`
	Total int                `json:"total"`
}
type AddInput struct {
	do.UserGroup
}
type AddOutput struct {
	Id int64 `json:"id"`
}
type UpdateInput struct {
	do.UserGroup
}
type UpdateOutput struct {
	Rows int64 `json:"rows" description:"修改成功的行数"`
}
type DeleteInput struct {
	Id         int64  `json:"id"`
	TenantCode string `json:"tenantCode"`
}
type DeleteOutput struct {
	Rows int64 `json:"rows" description:"删除成功的行数"`
}

type InfoInput struct {
	Id         int64  `json:"id"`
	TenantCode string `json:"tenantCode"`
}
type InfoOutput struct {
	Id    int64         `json:"id"`
	Users []entity.User `json:"users"`
}

type AssignUserInput struct {
	Id         int64   `json:"id"`
	TenantCode string  `json:"tenantCode"`
	Users      []int64 `json:"users"`
}
type AssignUserOutput struct {
	Id int64 `json:"id"`
}
type UnassignUserInput struct {
	Id         int64   `json:"id"`
	TenantCode string  `json:"tenantCode"`
	Users      []int64 `json:"users"`
}
type UnassignUserOutput struct {
	Rows int64 `json:"rows"`
}
